package strains;

import genes.AmbiguityCodes;
import genes.GeneSequence;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;


public class SequenceModify {

	
	@SuppressWarnings("unused")
	private static List<GeneSequence> removeAmbiguityCodes(List<GeneSequence> quartet) throws IOException {
		
			String gs1 = quartet.get(0).geneSequence;
			String gs2 = quartet.get(1).geneSequence;;
			String gs3 = quartet.get(2).geneSequence;;
			String gs4 = quartet.get(3).geneSequence;;
		
		
			HashSet<Integer> ambigityPos= new HashSet<Integer>();
			AmbiguityCodes ac= new AmbiguityCodes();
			int posi=0;
			int len= gs1.length();
			for(int i=0;i<=len;i++){
				char s1=gs1.charAt(posi);
				char s2=gs2.charAt(posi);
				char s3=gs4.charAt(posi);
				char s4=gs4.charAt(posi);
				if(ac.isAmbiguityCode(s1)){
					ambigityPos.add(posi);
				}
				if(ac.isAmbiguityCode(s2)){
					ambigityPos.add(posi);
				}
				if(ac.isAmbiguityCode(s3)){
					ambigityPos.add(posi);
				}
				if(ac.isAmbiguityCode(s4)){
					ambigityPos.add(posi);
				}
				posi++;
			}
			Iterator<Integer> acIter= ambigityPos.iterator();
			char[] gs1c= gs1.toCharArray();
			char[] gs2c= gs2.toCharArray();
			char[] gs3c= gs3.toCharArray();
			char[] gs4c= gs4.toCharArray();
			while(acIter.hasNext()){
				int remove =acIter.next();
				gs1c[remove]=' ';// or emtpy unicode amy
				gs2c[remove]=' ';// or emtpy unicode amy
				gs3c[remove]=' ';// or emtpy unicode amy
				gs4c[remove]=' ';// or emtpy unicode amy
			}
			List<GeneSequence> results= new ArrayList<GeneSequence>();
			results.add(new GeneSequence(String.valueOf(gs1c)));
			results.add(new GeneSequence(String.valueOf(gs2c)));
			results.add(new GeneSequence(String.valueOf(gs3c)));
			results.add(new GeneSequence(String.valueOf(gs4c)));
			
			return results;
		}
		

}
